<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <title>订单详情</title>
    <!--jquery-->
    <script type="text/javascript" src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!--bootstrap-->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!--jquery-validator-->
    <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
    <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
    <!--layui-->

    <script src="https://www.layuicdn.com/layui-v2.5.7/css/layui.css"></script>
    <script src="https://www.layuicdn.com/layui-v2.5.7/layui.js"></script>
    <!--common.js-->
    <script src="/js/common.js"></script>
</head>
<body>
<div class="panel panel-default">
    <div class="panel-heading">秒杀订单详情</div>
    <table class="table" id="order">
        <tr>
            <td>商品名称</td>
            <td id="goods.goodsName" colspan="3"></td>
        </tr>
        <tr>
            <td>商品图片</td>
            <td colspan="2"><img id="goodsImage" width="200" height="200"/> </td>
        </tr>
        <tr>
            <td>商品价格</td>
            <td colspan="2" id="goodsPrice"></td>
        </tr>
        <tr>
            <td>下单时间</td>
            <td colspan="2" id="createDate"></td>
        </tr>
        <tr>
            <td>订单状态</td>
            <td id="status">
                <!--<span th:if="${order.status eq 0}">未支付</span>-->
                <!--<span th:if="${order.status eq 1}">待发货</span>-->
                <!--<span th:if="${order.status eq 2}">已发货</span>-->
                <!--<span th:if="${order.status eq 3}">已收货</span>-->
                <!--<span th:if="${order.status eq 4}">已退款</span>-->
                <!--<span th:if="${order.status eq 5}">已完成</span>-->
            </td>
            <td>
                <button class="btn btn-primary btn-block" type="submit" id="payButton">立即支付</button>
            </td>
        </tr>
        <tr>
            <td>收货人</td>
            <td colspan="2"> XXXX</td>
        </tr>
        <tr>
            <td>收货地址</td>
            <td colspan="2">上海浦东</td>
        </tr>
    </table>
</div>
<script>
    $(function () {
        getOrderDetail();
    });
    function getOrderDetail() {
        var orderId = g_getQueryString("orderId");
        $.ajax({
            url:'/order/detail',
            type:'GET',
            data:{
                orderId:orderId
            },
            success:function (data) {
                if(data.code == 200){
                    render(data.object);
                }else{
                    layer.msg("客户端异常");
                }
            },
            error:function () {
                layer.msg("客户端异常");
            }
        })
    }
    function render(detail) {
        var goods = detail.goodsVO;
        var order = detail.order;
        $("#goodsName").text(goods.goodsName);
        $("#goodsImage").attr("src",goods.goodsImage);
        $("#goodsPrice").text(order.goodsPrice);
        $("#createDate").text(new Date(order.createDate).Format("yyyy-MM-dd hh:mm:ss"));
        var status = order.status;
        switch (status) {
            case 0:
                statusText = "未支付";
                break;
            case 1:
                statusText = "待发货";
                break;
            case 2:
                statusText = "已发货";
                break;
            case 3:
                statusText = "已收货";
                break;
            case 4:
                statusText = "已退款";
                break;
            case 5:
                statusText = "已完成";
                break;
        }
        $("#status").text(statusText);
        var statusText = "";
    }
</script>
</body>
</html>